/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2014.09.24                                          *
 * Description:      geom point of dim = FREEMAPS_DIM                    *
 * Acknowledgements: This file is a copy from libMesh projection         *
 *                   with slight modification.                           *
 *                                                                       *
 *************************************************************************/
#if 0
//declaration header
#include "COMMON/tbox/Point.h"

#include <iostream>

//COMMON headers
#include "COMMON/info/InfoManager.h"
#include "COMMON/info/CommonInfo.h"
#include "COMMON/tbox/InputDatabase.h"

namespace FreeMAPs
{

std::vector<double>
Point::to_vector () const
{
    const int dim = InfoManager::get_instance()->get_common_info()->get_dim();

    std::vector<double> array (dim);
    for (int i = 0; i < dim; ++i)
    {
        array[i] = (*this)(i);
    }

    return array;
}



void
Point::get_from_input (
    const InputDatabase* db,
    const std::string& key,
    const bool check_dim)
{
    FREEMAPS_ASSERT_VALID_POINTER (db);

    /*
     * do not check the allowable keys here
     * because it is usually called in a database and checked there.
     */

    db->check_requisite_key (key, DataType::DOUBLE, false, true);
    if (check_dim)
    {
        db->check_vec_size_of_dim (key);
    }
    std::vector<double> point = db->get_double_vector (key);

    this->create (point);
}



std::ostream&
operator << (
    std::ostream& os,
    const Point& rhs)
{
//    const int dim = 3;
    const int dim = InfoManager::get_instance()->get_common_info()->get_dim();
    for (int i = 0; i < dim; ++i)
    {
        //os.precision (6);
        //os.width(FREEMAPS_DOUBLE_WIDTH);
        //os.setf(std::ios::right);
        os << rhs(i);
        if (i < (dim - 1))
        {
            os << ", ";
        }
    }

    return os;
}



void
PointCmp::check()
{
    Point p1 (0, 0);
    Point p2 (1, 1);
    Point p3 (1+1.e-15, 1);
    Point p4 (2, 2);
    std::set<Point, PointCmp> ps;
    ps.insert (p1);
    ps.insert (p2);
    std::cout << "ps has p2 " << ps.count (p2) << ", has p3 " << ps.count (p3) << ", do not has p4 " << ps.count (p4) << std::endl;
    FREEMAPS_ERROR ("stop here");
}

}

#endif
